<template>
  <view>
    <u-navbar title="签到" autoBack fixed placeholder></u-navbar>
    <view class="content">
      <z-paging ref="paging" fixed use-safe-area-placeholder refresher-vibrate refresher-background="#f5f5f5"
			@query="onRefresh" safe-area-inset-bottom show-refresher-when-reload refresher-only  show-refresher-update-time
			style="top: calc(44px + var(--status-bar-height));" @scroll="onScroll">
        <u-gap height="10px" bgColor="#f5f5f5"></u-gap>
        <view v-if="dataList.length != 0">
          <u-cell v-for="item in dataList" :key="item.id" :title="item.subject" :label="`截止：${item.end_time}`" 
          :value="item.timeout  ? '已结束' : '进行中'" isLink @click="goSign(item)"></u-cell>
          <u-loadmore :status="loadMore" :marginTop="20" :marginBottom="20"></u-loadmore>
        </view>
        <u-empty v-else icon="/static/sign_data.png" text="暂无签到记录"></u-empty>
      </z-paging>
    </view>

    <c-loading></c-loading>
  </view>
</template>

<script>
import {
  getSignList
} from '@/api/subject'
import mixin from '@/mixin'
export default {
  components: {},
  data() {
    return {

    }
  },
  mixins: [mixin],
  created() {
    this.getDataList(false)
  },
  methods: {
    getDataList(isRefresh) {
      const params = {}
      params.current = this.current
      params.size = 20
      params.id = this.$store.getters.id
      params.type = '1'
      getSignList(params).then(res => {
        console.log(res);
        if(res.code === 200) {
          this.total = res.data.total
          if(isRefresh) {
            this.dataList = []
          }
          res.data.list.forEach(item => {
            this.dataList.push(item)
          })
        }
        this.$refs.paging.complete()
      }).catch(e => {
        this.$refs.paging.complete()
      })
    },
    goSign(item) {
      uni.navigateTo({
        url: `/pages/menus/sign/detail?item=${JSON.stringify(item)}`
      })
    }
  },
} 
</script>

<style scoped></style>